import React from 'react';
import { MouseEvent } from 'react';
import './App.css';

function App() {
  const click = (event: MouseEvent) => {
    event.stopPropagation();
    console.log('aaaa.....');
  };
  const flag = true;

  function Hello() {
    if (flag) return <div>aaa</div>;
    return <div>bbbb</div>;
  }

  const list = [
    { name: 'zs', userName: '章三' },
    { name: 'ls', userName: '里斯' },
    { name: 'wu', userName: '王五' },
    { name: 'zy', userName: '志愿' },
  ];

  return (
    <div className="App">
      <header className="App-header">
        {flag ? <p>hello</p> : <p>world</p>}
        <Hello />
        <ul>
          {list?.map(itm => {
            const { name, userName } = itm;
            return <li key={name}>{userName}</li>;
          })}
        </ul>
        <p>
          Edit <code>src/App.tsx</code> and save to reload.
        </p>
        <button onClick={click}>click</button>
        <p>你好</p>
        <a
          className="App-link"
          href="https://reactjs.org"
          target="_blank"
          rel="noopener noreferrer"
        >
          Learn React
        </a>
      </header>
    </div>
  );
}

export default App;
